//
//  UIDevice+SGExtension.swift
//  Swift-Codedase
//
//  Created by xyanl on 2023/7/25.
//

import UIKit

extension UIDevice {
    
    /// 顶部安全区域高度
    static var topSafeHeight: CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let window = windowScene.windows.first else { return 0 }
        return window.safeAreaInsets.top
    }
    
    /// 底部安全区域高度
    static var bottomSafeHeight: CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let window = windowScene.windows.first else { return 0 }
        return window.safeAreaInsets.bottom
    }
    
    /// 顶部状态栏高度（包括安全区）
    static var statusBarHeight: CGFloat {
        let scene = UIApplication.shared.connectedScenes.first
        guard let windowScene = scene as? UIWindowScene else { return 0 }
        guard let statusBarManager = windowScene.statusBarManager else { return 0 }
        return statusBarManager.statusBarFrame.height
    }
    
    /// 导航栏高度
    static var navBarHeight: CGFloat {
        44.0
    }
    
    /// 状态栏+导航栏的高度
    static var navBarFullHeight: CGFloat {
        UIDevice.navBarHeight+UIDevice.statusBarHeight
    }
    
    /// 底部导航栏高度
    static var tabBarHeight: CGFloat {
        49.0
    }
    
    /// 底部导航栏高度（包括安全区）
    static var tabBarFullHeight: CGFloat {
        UIDevice.tabBarHeight + UIDevice.bottomSafeHeight
    }
}
